package models;

import	java.util.*;
import	javax.persistence.*;

import play.data.validation.*;
import	play.db.jpa.*;

@Entity
public class User extends Model{
	
	@Required
	public String login;
	
	@Required
	public String password;
	
	@Required
	public String fullname;
	public Boolean isAdmin;
	
	public User (String login, String password, String fullname, Boolean isAdmin)
	{
		this.login 		= login;
		this.fullname 	= fullname;
		this.password 	= password;
		this.isAdmin 	= isAdmin;
	}
	
	public static User connect(String login, String password)
	{
		return find("byLoginAndPassword", login, password).first();
	}
	
	public String toString()
	{
		return fullname;
	}
}